<template>
  <a-drawer
    :title="title"
    placement="right"
    :closable="true"
    :width="width"
    :visible="visible"
    @close="handleCancel"
    destroyOnClose
  >
    <a-tabs type="card">
      <a-tab-pane key="1" tab="退货订单信息">
        <goods-rejected-order-info-tab ref="goodsRejectedOrderInfoTab" :record="model"></goods-rejected-order-info-tab>
      </a-tab-pane>
      <a-tab-pane key="2" tab="订单材料信息">
        <goods-rejected-material-info-tab ref="inDepositoryMaterialInfoTab" :materialData="materialData" :record="model"></goods-rejected-material-info-tab>
      </a-tab-pane>
    </a-tabs>
  </a-drawer>


  <!--<j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :footer="null"
    switchFullscreen
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel="handleCancel"
    cancelText="关闭">
    <div>
      <a-row>
        <a-col :span="5">
          <span style="font-weight: bold">编号：</span>{{model.purchaseNo}}
        </a-col>
        <a-col :span="5">
          <span style="font-weight: bold">退货日期：</span>{{model.goodsRejectedTime}}
        </a-col>
        <a-col :span="5">
          <span style="font-weight: bold">采购人员：</span>{{model.purchasePeople}}
        </a-col>
        <a-col :span="5">
          <span style="font-weight: bold">供应商：</span>{{model.supplierName}}
        </a-col>
        <a-col :span="4">
          <span style="font-weight: bold">仓库：</span>{{model.depositoryName}}
        </a-col>
      </a-row>
    </div>
    <div style="margin-top: 15px;margin-bottom: 15px">
      <a-row>
        <a-col :span="5">
          <span style="font-weight: bold">创建人：</span>{{model.createBy}}
        </a-col>
        <a-col :span="5">
          <span style="font-weight: bold">创建时间：</span>{{model.createTime}}
        </a-col>
        <a-col :span="5">
          <span style="font-weight: bold">订单状态：</span>{{getOrderStatusValue(model.orderStatus)}}
        </a-col>
        <a-col :span="6">
          <span style="font-weight: bold">备注：</span>{{model.remark == null || model.remark == "" ? "无":model.remark}}
        </a-col>
        <a-col :span="3">
          <a-button style="margin-right: 10px;margin-left: 10px" type="primary" @click="leadingOut">导出Excel</a-button>
        </a-col>
      </a-row>
    </div>
    <div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        class="j-table-force-nowrap"
        bordered
        :data-source="materialData"
        :columns="columns"
        :pagination="false"
        :rowKey="(record,index)=>{return index}"
      >
      </a-table>

      <a-row style="margin-top: 20px">
        <a-col :span="6">
          合计：<a-input-number v-model="model.purchasePrice" disabled></a-input-number>
        </a-col>
        <a-col :span="6">
          优惠率：<a-input-number v-model="model.discountedRate" disabled></a-input-number>&nbsp;%
        </a-col>
        <a-col :span="6">
          优惠金额：<a-input-number v-model="model.discountedMoney" disabled></a-input-number>
        </a-col>
        <a-col :span="6">
          优惠后金额：<a-input-number v-model="model.discountedPurchasePrice" disabled></a-input-number>
        </a-col>
      </a-row>
    </div>
  </j-modal>-->
</template>

<script>
  import { getAction } from '@/api/manage'
  import '@/assets/less/TableExpand.less'
  import goodsRejectedOrderInfoTab from "./tab/goodsRejectedOrderInfoTab";
  import goodsRejectedMaterialInfoTab from "./tab/goodsRejectedMaterialInfoTab";

  export default {
    name: 'goodsRejectedOrderDetailModal',
    components: {
      goodsRejectedOrderInfoTab,
      goodsRejectedMaterialInfoTab,
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },

    data() {
      return {
        materialData: [],
        columns: [
          {
            title: '#',
            dataIndex: '',
            key: 'rowIndex',
            width: '3%',
            align: "center",
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }
          },
          {
            title: '名称',
            dataIndex: 'materialName',
            width: '13%',
            align: "center",
            scopedSlots: {customRender: 'materialName'},
          },
          {
            title: '型号',
            dataIndex: 'modelNumber',
            width: '12%',
            align: "center",
            scopedSlots: {customRender: 'modelNumber'},
          },
          {
            title: '规格',
            dataIndex: 'specifications',
            width: '13%',
            align: "center",
            scopedSlots: {customRender: 'specifications'},
          },
          {
            title: '品牌',
            dataIndex: 'brand',
            width: '12%',
            align: "center",
            scopedSlots: {customRender: 'brand'},
          },
          {
            title: '单位',
            align: "center",
            width: '5%',
            dataIndex: 'unit'
          },
          {
            title: '市场价',
            dataIndex: 'marketPrice',
            width: '5%',
            align: "center",
            scopedSlots: {customRender: 'marketPrice'},
          },
          {
            title: '预算价',
            dataIndex: 'estimatedCost',
            width: '5%',
            align: "center",
            scopedSlots: {customRender: 'estimatedCost'},
          },
          {
            title: '成本价',
            dataIndex: 'costPrice',
            width: '5%',
            align: "center",
          },
          {
            title: '单价',
            dataIndex: 'unitPrice',
            width: '5%',
            align: "center",
            scopedSlots: {customRender: 'unitPrice'},
          },
          {
            title: '数量',
            dataIndex: 'materialNum',
            width: '5%',
            align: "center",
            scopedSlots: {customRender: 'materialNum'},
          },
          {
            title: '折扣率(%)',
            dataIndex: 'discountRate',
            width: '7%',
            align: "center",
            scopedSlots: {customRender: 'discountRate'},
          },
          {
            title: '折扣额',
            dataIndex: 'discountMoney',
            width: '7%',
            align: "center",
            scopedSlots: {customRender: 'discountMoney'},
          },
          {
            title: '折后单价',
            dataIndex: 'discountUnitPrice',
            width: '7%',
            align: "center",
            scopedSlots: {customRender: 'discountUnitPrice'},
          },
          {
            title: '小计金额',
            dataIndex: 'subtotal',
            width: '5%',
            align: "center",
            scopedSlots: {customRender: 'subtotal'},
          },
          {
            title: '备注',
            dataIndex: 'remark',
            width: '12%',
            align: "center",
            scopedSlots: {customRender: 'remark'},
          },
        ],
        title: '',
        width: '100%',
        visible: false,
        disableSubmit: false,
        fullscreen: true,
        model: {},
        labelCol: {
          xs: {span: 24},
          sm: {span: 5},
        },
        wrapperCol: {
          xs: {span: 24},
          sm: {span: 16},
        },
        statusValue:"",
        url: {
          queryGoodsRejectedOrderItemList: "/ghSupplychainPurchaseOrderItem/list",
        }
      }
    },
    computed: {
      formDisabled() {
        return this.disabled
      },
    },
    created() {

    },
    methods: {
      getOrderStatusValue(status){
        switch (status) {
          case 1:
            this.statusValue = "草稿"
            return "草稿"
          case 2:
            this.statusValue = "审批中"
            return "审批中"
          case 3:
            this.statusValue = "审批通过"
            return "审批通过"
          case 4:
            this.statusValue = "未通过"
            return "未通过"
          case 5:
            this.statusValue = "已撤销"
            return "已撤销"
        }
      },
      showDetail(record) {
        this.getOrderStatusValue(record.orderStatus)
        this.model = Object.assign({}, record);
        this.model.statusValue = this.statusValue;
        getAction(this.url.queryGoodsRejectedOrderItemList, {
          id: record.id
        }).then((res) => {
          if (res.success) {
            this.materialData = res.result.records || res.result;
          }
        })
        this.visible = true;
      },
      close() {
        this.$emit('close');
        this.visible = false;
      },
      handleCancel() {
        this.close()
      },
    }
  }
</script>
<style scoped>
  .editable-row-operations a {
    margin-right: 8px;
  }

  .tableHiddle {
    display: none;
  }
</style>